<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <!--<title>EVA MOVIL</title>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
        <link rel="stylesheet" href="../css/style.css" />
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
        <script src="../scripts/utpljs.js"></script>-->  
    </head>
    <body>
        <?php
             header('Content-Type: text/html; charset=iso-8859-1');
            global $USER, $CFG, $COURSE;
            require_once('../../config.php');
             require_once('../lib/lib.php');
            $curso = $_POST['courseid'];
            $oper = $_POST['oper'];
            //$curso = 35742;
            
            if( !empty ($curso) ){
                
                $COURSE = get_record("course", "id",$curso);
                if(! $COURSE){
                    echo "<h1>Curso desconocido<h1>";
                }
            }
             
            ////data-title="<?php echo "$COURSE->fullname";"
            //data-add-back-btn="true"
       if( !empty( $curso ) && $oper == "get_curso"){
        ?>
        
        <div data-role="page"  id="menucourse" class="courseop"  >

                <div data-theme="b" data-role="header">
                   <a href="#courselist"  class="muro" data-role="button" data-icon="arrow-l" data-transition="fade" data-iconpos="notext">Home</a>         
                        <h1><?php echo $COURSE->fullname; ?></h1>
                   <a href="login.php" class="salir" data-role="button" data-icon="delete" data-transition="fade" data-iconpos="notext">Salir</a>               
                </div><!-- /header -->

                <div data-role="content">
                         <?php 
                            $teachers= get_teachers($curso);
                            
                            foreach($teachers as $teacher){
                                $profeid = $teacher->id;
                                $datos_nm .= "<h3>".$teacher["name"]."</h3>";
                            }
                            $anuncios = get_records_sql("SELECT 
                                                                cs.id,  cs.summary,l.time            
                                                            FROM 
                                                                {$CFG->prefix}course_sections as cs, {$CFG->prefix}log as l  
                                                            WHERE 
                                                                cs.visible = 1 and cs.course = $COURSE->id
                                                                and cs.summary <> '' 
                                                                and cs.course = l.course 
                                                                and l.action = 'editsection'  and cs.section = l.info order by (cs.id) DESC");
                         ?>
                       <ul data-role="listview" data-inset="true" data-count-theme="e">                             
                             <li data-role="list-divider"><?php echo $COURSE->fullname; ?></p></li>
                             <!--<div class="ui-grid-a">-->
                                    <div style="width: 15%" class="ui-btn-left">
                                        <img src="<?php echo $CFG->wwwroot; ?>/user/pix.php?file=<?php echo $profeid;  ?>/f1.jpg"  alt="Usuario picture"/>
                                    </div>
                                    <div style="width: 75%" class="ui-btn-right">
                                        <strong>Facilitador(es):</strong>
                                        <h2><?php echo $datos_nm; ?></h2>
                                    </div>
                            <!--</div><!-- /grid-a class="link_interno" id="pag_anuncios" -->
                            
                             <li><a data-transition="slide" class="link_interno" id="pag_anuncios"   href="#"><img height="25px" width="25px" src="imgs/anuncio.png" alt="Anuncio" class="ui-li-icon">Anuncios<span class="ui-li-count"><?php echo count($anuncios) ?></a></li> 
                             <li><a data-transition="slide" class="link_interno" id="pag_tareas"  href="#"><img height="25px" width="25px" src="imgs/tareas.png" alt="Tareas" class="ui-li-icon">  Tareas<span class="ui-li-count"><?php echo count( get_tareas($curso) ); ?></span></a></li> 
                             <li><a data-transition="slide" class="link_interno" id="pag_foros"  href="#"><img height="25px" width="25px" src="imgs/forum.png" alt="Foros" class="ui-li-icon">Foros<span class="ui-li-count"><?php echo count( get_foros($curso) ); ?></span></a>
                             </li>
                        </ul>
                        
                </div><!-- /content -->

                <div data-theme="b" data-role="footer">
                       <h5>
                         <img src="imgs/logo2.png" whith="50px" height="40px"   alt="logo utpl"/>
                       </h5>
                </div><!-- /footer -->
        </div><!-- /page -->
        
        
        <?php
       } 
       
       if(!empty( $curso ) && $oper == "get_anuncios"){
           if(!$COURSE || $COURSE->id == 0){
               $COURSE = get_record("course", "id", $curso);
           }
        ?>
        
        <div data-role="page"  id="anuncios" data-title="Anuncios" class="courseop"  >

                <div data-theme="b" data-role="header">
                   <a href="#menucourse" class="muro" data-role="button" data-icon="arrow-l" data-transition="fade" data-iconpos="notext">Home</a>              
                        <h1><?php echo "$COURSE->fullname";  ?></h1>
                   <a href="login.php" class="salir" data-role="button" data-icon="delete" data-transition="fade" data-iconpos="notext">Salir</a>               
                </div><!-- /header -->

                <div id="content_anun" data-role="content">
                        
                       <?php
                                $anuncios = get_records_sql("SELECT 
                                                                cs.id,  cs.summary,l.time            
                                                            FROM 
                                                                {$CFG->prefix}course_sections as cs, {$CFG->prefix}log as l  
                                                            WHERE 
                                                                cs.visible = 1 and cs.course = $COURSE->id
                                                                and cs.summary <> '' 
                                                                and cs.course = l.course 
                                                                and l.action = 'editsection'  and cs.section = l.info order by (cs.id) DESC");
                                if($anuncios){    
                                    echo '<ul data-role="listview">';
                                    foreach( $anuncios as $anuncio){                                                        

                                        echo '<li>
                                                            <p class="ui-li-aside"><strong>'.  get_fecha($anuncio->time) .'<strong></p><br>
                                                            <h3>'. utf8_decode($anuncio->summary).'</h3>
                                                            <br>
                                                            <!--<a class="ui-btn-right" href="#"><img src="imgs/comments-icon.png"  alt="comentarios"></a>-->
                                                            '. get_comentarios_rsa($COURSE->id, $anuncio->id).'
                                                      </li>';
                                    }//    
                                       echo  '</ul> ';//<a href="#" id="exit" data-theme="e" data-role="button" data-icon="gear" data-transition="fade" data-inline="true">Modificar</a><br>
                                    //<div class="red-soc"><a href="#"><img src="../imgs/comments-icon.png"  alt="comentarios"></a></div>
                                       /*
                                        * Funciones para la administracion de anuncios (agregar, eliminar, ocultar)
                                        */
                                       if( es_profesor_curso($COURSE->id , $USER->id) ){
                                           echo '<br><div data-role="navbar">
                                                <ul>
                                                        <li><a data-icon="add" data-iconpos="top" data-rel="dialog" href="#add_anuncio_dialog" class="ui-btn-active">Agregar</a></li>
                                                        <li><a data-icon="add" data-iconpos="top" href="#">Ocultar</a></li>
                                                        <li><a data-icon="delete" data-iconpos="top" href="#">Eliminar</a></li>
                                                </ul>
                                            </div><!-- /navbar -->';
                                       }
                                        
                                        
                                }else{
                                    echo "<h1>No Existen Anuncios<h1>";
                                }
                        ?>
                        
                </div><!-- /content -->

                <div data-theme="b" data-role="footer">
                       <h5>
                         <img src="imgs/logo2.png" whith="50px" height="40px"   alt="logo utpl"/>
                       </h5>
                </div><!-- /footer -->
        </div><!-- /page -->
        
         <?php
         }
          if(!empty( $curso ) && $oper == "get_tareas"){
              if(!$COURSE || $COURSE->id == 0){
               $COURSE = get_record("course", "id", $curso);
              }
        ?>
        
            <div data-role="page" id="tareas"  data-title="Tareas" class="courseop"  >

                <div data-theme="b" data-role="header">
                   <a href="#menucourse" class="muro" data-role="button" data-icon="arrow-l" data-transition="fade" data-iconpos="notext">Home</a>               
                        <h1><?php echo "$USER->firstname $USER->lastname ";  ?></h1>
                   <a href="login.php" class="salir" data-role="button" data-icon="delete" data-transition="fade" data-iconpos="notext">Salir</a>               
                </div><!-- /header -->

                <div data-role="content">
                   <?php      
                      $tareas = get_tareas($COURSE->id);
                   //print_object($tareas);
                   if($tareas){       
                ?>
                <ul data-role="listview" data-inset="true" data-count-theme="e">                             
                             <li data-role="list-divider">Tareas</p></li>
                             <?php
                               foreach($tareas as $tarea){
                                   echo '<li>                                                             
                                        <p>                                           
                                           <h1>'. utf8_decode($tarea->name).'</h1>
                                           <p>'.utf8_decode($tarea->description).'</p>
                                        </p>                                    
                                        <span class="ui-li-count">nota ('.$tarea->grade.')</span>
                                    </li>';
                               }
                                 
                             ?>                             
                             </li>
                </ul>
                <?php
                   }else{
                       echo "<h1>No se ha registrado tareas hasta el momento<h1>";
                   }
                ?>
                        
                </div><!-- /content -->

                <div data-theme="b" data-role="footer">
                       <h5>
                         <img src="imgs/logo2.png" whith="50px" height="40px"   alt="logo utpl"/>
                       </h5>
                </div><!-- /footer -->
        </div><!-- /page -->
        
         <?php
          }
           if(!empty( $curso ) && $oper == "get_foros"){
               if(!$COURSE || $COURSE->id == 0){
                 $COURSE = get_record("course", "id", $curso);
               }
        ?>
        
        <div data-role="page"  id="foros" data-title="Foros" class="courseop" >

                <div data-theme="b" data-role="header">
                   <a href="#menucourse" class="muro" data-role="button" data-icon="arrow-l" data-transition="fade" data-iconpos="notext">Home</a>               
                        <h1><?php echo "$USER->firstname $USER->lastname ";  ?></h1>
                   <a href="login.php" class="salir" data-role="button" data-icon="delete" data-transition="fade" data-iconpos="notext">Salir</a>               
                </div><!-- /header -->

                <div data-role="content">
                         
                       <?php
                   $foros = get_foros($COURSE->id);
                   //print_object($tareas);
                   if($foros){       
                ?>
                <ul data-role="listview" data-inset="true" data-count-theme="e">                             
                             <li data-role="list-divider">Foros</p></li>
                             <?php
                               foreach($foros as $foro){
                                   echo '<li>                                                             
                                        <p>                                           
                                           <h1>'. utf8_decode ($foro->name) .'</h1>
                                           '. utf8_decode($foro->intro) .'
                                        </p>                                    
                                        
                                    </li>';
                               }
                                 
                             ?>                             
                             </li>
                </ul>
                <?php
                   }else{
                       echo "<h1>No se ha registrado foros hasta el momento<h1>";
                   }
                ?>
                        
                </div><!-- /content -->

                <div data-theme="b" data-role="footer">
                       <h5>
                         <img src="imgs/logo2.png" whith="50px" height="40px"   alt="logo utpl"/>
                       </h5>
                </div><!-- /footer -->
        </div><!-- /page -->
      
        
        <?php 
           }
           if( !empty( $curso ) && $oper == "anuncio_dialog"){  
               if(!$COURSE || $COURSE->id == 0){
                 $COURSE = get_record("course", "id", $curso);
               }
        ?>
        <div data-role="dialog" id="add_anuncio_dialog" data-title="Agregar Anuncio" class="courseop" >
                <div data-role="content">
                        <h1>Agregar Anuncio</h1> 
                        <form id="form_sanuncio" url="">
                            <div data-role="fieldcontain">
                                <fieldset data-role="controlgroup">
                                    <label for="txt_anuncio">
                                        Anuncio
                                    </label>
                                    <textarea id="txt_anuncio" name="txt_anuncio" placeholder="">
                                      
                                    </textarea>
                                </fieldset>
                                <input type="hidden" id="curso" name="curso" value="<?php echo $curso; ?>" />
                                <input type="hidden" id="userid" name="userid" value="<?php echo $USER->id; ?>" />
                                <input type="hidden" id="oper" name="oper" value="save_anuncio" />
                            </div>
                            <a data-role="button" id="btn_add_anuncio" data-theme="a" data-transition="fade" href="#" data-icon="check" data-iconpos="top">
                                Aceptar
                            </a>
                            <a data-role="button" data-transition="slide" href="#anuncios" data-icon="delete" data-iconpos="top">
                                Cancelar
                            </a>
                        </form>
                </div><!-- /content -->                
        </div><!-- /page -->
        
        <?php 
           }        
        ?>
        
        
        
    </body>
</html>
